[collectionId]-187c9af4c69f1582.js.map 3.8 KB

1
  1. {"version":3,"file":"static/chunks/pages/collections/[collectionId]-187c9af4c69f1582.js","mappings":"uFACKA,OAAOC,SAAWD,OAAOC,UAAY,IAAIC,KAAK,CAC7C,8BACA,WACE,OAAO,EAAQ,W,sKCgEvB,UAzD6B,WAC3B,IAAMC,GAASC,EAAAA,EAAAA,aACaC,GAAAA,EAAAA,EAAAA,UAASC,EAAAA,EAAAA,UAA9BC,EAAqBF,EAA6C,GAA1DG,EAAaH,EAA6C,GAOnEI,EAAeN,EAAOO,MAAMD,aA4BlC,OACE,SAACE,EAAAA,EAAyB,CAACJ,OAAQA,EAAQK,UAf9B,SAACC,EAAWC,G,IAOVA,EANf,GAAIA,IAAqBA,EAAiBC,KAAM,OAAO,KACvD,GAAkB,IAAdF,EACF,OAAOG,EAAAA,EAAAA,IAA8BP,EAAc,CACjDF,OAAAA,IAGJ,IAAMU,EAAoC,QAA3BH,EAAAA,EAAiBI,kBAAU,IAA3BJ,OAAAA,EAAAA,EAA6BK,UAC5C,OAAOH,EAAAA,EAAAA,IAA8BP,EAAc,CACjDF,OAAAA,EACAU,OAAAA,KAK4DG,eAlCzC,SAACC,IACtBC,EAAAA,EAAAA,IAAe,iCAAkCf,EAAQc,GACzDb,EAAUa,S","sources":["webpack://_N_E/?13af","webpack://_N_E/./src/pages/collections/[collectionId]/index.tsx"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/collections/[collectionId]\",\n function () {\n return require(\"private-next-pages/collections/[collectionId]/index.tsx\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/collections/[collectionId]\"])\n });\n }\n ","import { useState } from 'react';\n\nimport { GetStaticPaths, GetStaticProps } from 'next';\nimport { useRouter } from 'next/router';\n\nimport CollectionDetailContainer from '@/components/Collection/CollectionDetailContainer/CollectionDetailContainer';\nimport { logValueChange } from '@/utils/eventLogger';\nimport { makeGetBookmarkByCollectionId } from 'src/utils/auth/apiPaths';\nimport { getAllChaptersData } from 'src/utils/chapter';\nimport { CollectionDetailSortOption } from 'types/CollectionSortOptions';\n\nconst CollectionDetailPage = () => {\n const router = useRouter();\n const [sortBy, setSortBy] = useState(CollectionDetailSortOption.VerseKey);\n\n const onSortByChange = (newSortByVal) => {\n logValueChange('collection_detail_page_sort_by', sortBy, newSortByVal);\n setSortBy(newSortByVal);\n };\n\n const collectionId = router.query.collectionId as string;\n /**\n * Get the SWR key for cursor based pagination\n * - when the page index is still 0 (first fetch). the get the bookmarkByCollection url without `cursor` param\n * - on the next fetch, add `cursor` to the parameters\n *\n * corner case\n * - when previous fetch contains empty data, stop fetching\n * - when the user is logged out, don't fetch the data\n *\n * Reference: https://swr.vercel.app/docs/pagination#useswrinfinite\n *\n * @returns {string} swr key\n */\n const getKey = (pageIndex, previousPageData) => {\n if (previousPageData && !previousPageData.data) return null;\n if (pageIndex === 0) {\n return makeGetBookmarkByCollectionId(collectionId, {\n sortBy,\n });\n }\n const cursor = previousPageData.pagination?.endCursor;\n return makeGetBookmarkByCollectionId(collectionId, {\n sortBy,\n cursor,\n });\n };\n\n return (\n <CollectionDetailContainer sortBy={sortBy} getSWRKey={getKey} onSortByChange={onSortByChange} />\n );\n};\n\nexport const getStaticProps: GetStaticProps = async ({ locale }) => {\n const allChaptersData = await getAllChaptersData(locale);\n\n return {\n props: {\n chaptersData: allChaptersData,\n },\n };\n};\n\nexport const getStaticPaths: GetStaticPaths = async () => ({\n paths: [], // no pre-rendered chapters at build time.\n fallback: 'blocking', // will server-render pages on-demand if the path doesn't exist.\n});\n\nexport default CollectionDetailPage;\n"],"names":["window","__NEXT_P","push","router","useRouter","useState","CollectionDetailSortOption","sortBy","setSortBy","collectionId","query","CollectionDetailContainer","getSWRKey","pageIndex","previousPageData","data","makeGetBookmarkByCollectionId","cursor","pagination","endCursor","onSortByChange","newSortByVal","logValueChange"],"sourceRoot":""}